package builder;

interface GA{
    GA createA();
    GA createB();
    GA createC();
    All build();
}

class All{
    A a;
    B b;
    C c;
}
class A{

}
class B{

}
class C{

}

class CreateAll implements GA{
    private All all = new All();
    @Override
    public GA createA() {
        all.a = new A();
        return this;
    }

    @Override
    public GA createB() {
        all.b = new B();
        return this;
    }

    @Override
    public GA createC() {
        all.c = new C();
        return this;
    }

    @Override
    public All build() {
        // 最后得到复杂的 build类型
        return all;
    }
}

public class builder {
    public static void main(String[] args){

        CreateAll createAll = new CreateAll();
        All all = createAll.createA().createB().createC().build();

        System.out.println(all);
    }
}
